package com.springboot.controller;

import com.springboot.domain.NewUser;
import com.springboot.domain.Role;
import com.springboot.service.BaseService;
import com.springboot.service.UserServiceI;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/uc")
public class UserController extends BaseController<NewUser> {


    @Resource(name = "userServiceI")
    private UserServiceI bs;

    @Override
    public List<NewUser> find(NewUser newUser) {
        return bs.find(newUser);
    }

    @Override
    public Map<String, Object> add(NewUser newUser) {
        return bs.add(newUser);
    }


    @RequestMapping("/batchAdd")
    @ResponseBody
    public Map<String, Object> add(String users) {
        users = "[{\"password\":\"123\",\"loginName\":\"用户名123\",\"birthday\":\"1990-10-10\"}," +
                "{\"password\":\"456\",\"loginName\":\"用户名456\",\"birthday\":\"2000-02-03\"}," +
                "{\"password\":\"789\",\"loginName\":\"用户名789\",\"birthday\":\"1998-11-12\"}" +
                "]";
        return bs.add(users);
    }

    @RequestMapping("/findRole")
    @ResponseBody
    public List<Role> find(Role r) {
        return bs.find(r);
    }


    @RequestMapping("/findRoleMenus")
    @ResponseBody
    public List<Role> findRoleMenus(Role r) {
        return bs.findRoleMenus(r);
    }


}
